﻿#region using statements

using System;

using Microsoft.Xna.Framework;

#endregion

namespace NGen.Managers.Pathfinding
{
	public struct PathfindingCell : IComparable<PathfindingCell>
	{
		/// <summary>
		/// 	The movement cost incurred so far
		/// </summary>
		internal double m_gCost;

		/// <summary>
		/// 	The heuristic cost to the goal
		/// </summary>
		internal double m_hCost;

		/// <summary>
		/// 	This cells location in the _cellMap
		/// </summary>
		internal Point m_location;

		/// <summary>
		/// 	The reference to the cell which comes before this one in the final
		/// 	path
		/// </summary>
		internal Point m_previousCell;

		/// <summary>
		/// 	Get _hCost + _gCost
		/// </summary>
		internal double _TotalCost {
			get { return m_hCost + m_gCost; }
		}

		public Point GetLocation {
			get { return m_location; }
		}

		#region IComparable<PathfindingCell> Members

		/// <summary>
		/// 	Compares this PathfindingCell to the one passed in
		/// </summary>
		/// <param name = "p_other">the PathfindingCell to compare</param>
		/// <returns>1 if this cell is greater</returns>
		public int CompareTo(PathfindingCell p_other) {
			return _TotalCost > p_other._TotalCost ? 1 : (_TotalCost < p_other._TotalCost ? -1 : 0);
		}

		#endregion
	}
}